package com.yuyou.tas.gateway;

import javax.annotation.PreDestroy;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.Bean;

import com.netflix.discovery.DiscoveryManager;
import com.yuyou.tas.gateway.filter.AccessFilter;
import com.yuyou.tas.gateway.filter.ErrorFilter;
import com.yuyou.tas.gateway.filter.LogFilter;
import com.yuyou.tas.gateway.filter.TerminalAccessFilter;
import com.yuyou.tas.gateway.filter.TerminalLogFilter;

@SpringBootApplication
@EnableZuulProxy
public class TasGatewayApplication {

	@Bean
	public ErrorFilter errorFilter() {
	return new ErrorFilter() ;
	}
	
	@Bean
	public AccessFilter accessFilter() {
	return new AccessFilter() ;
	}
	
	@Bean
	public TerminalAccessFilter terminalAccessFilter() {
	return new TerminalAccessFilter() ;
	}
		
	@Bean
	public LogFilter logFilter() {
	return new LogFilter() ;
	}
	
	@Bean
	public TerminalLogFilter terminalLogFilter() {
	return new TerminalLogFilter() ;
	}
	
	public static void main(String[] args) {
		SpringApplication.run(TasGatewayApplication.class, args);
	}
	
	@SuppressWarnings("deprecation")
	@PreDestroy
	public void dostory() {
		DiscoveryManager.getInstance().shutdownComponent();
	}
}
